# -*- coding: utf-8 -*-
from utils.operators.spark_submit import SparkSubmitOperator
from datetime import timedelta

from jms.dm import jms_dm__dm_waybill_collect_intime_detail, jms_dm__dm_cn_departure_transfer_timely_route_dt, \
    jms_dm__dm_cn_departure_transfer_timely_route_dt_t2
from jms.dwd import jms_dwd__dwd_centersend_timerate_detail_dt
from jms.ods import jms_ods__yl_lmdm_sys_network, jms_ods__yl_tmsnew_tms_shipment_stop, \
    jms_ods__yl_tmsnew_branch_shipment_stop, jms_ods__yl_tmsnew_tms_shipment, jms_ods__yl_tmsnew_branch_shipment, \
    jms_ods__electronic_package_list, jms_ods__second_package_list, jms_ods__tab_report_errorbagging_detail
from jms.dwd.dwd_route_basic_detail_dt_input import jms_dwd__dwd_route_basic_detail_dt_input
from jms.dwd.dwd_scan_detail_dt import jms_dwd__dwd_scan_detail_dt

jms_dwd__dwd_dynamic_route_detail_dt = SparkSubmitOperator(
    task_id='jms_dwd__dwd_dynamic_route_detail_dt',
    email=['suning@jtexpress.com','yl_bigdata@yl-scm.com'],
    name='jms_dwd__dwd_dynamic_route_detail_dt_{{ execution_date | date_add(1) | cst_ds }}',
    conn_id='spark_route',
    pool_slots=5,
    driver_memory='20G',
    driver_cores=2,
    executor_memory='30G',
    executor_cores=4,
    num_executors=100,
    conf={'spark.sql.shuffle.partitions': 600,
          'spark.driver.maxResultSize': 2048,
          'spark.executor.memoryOverhead': 2048,
          'spark.core.connection.ack.wait.timeout': 300,
          'spark.default.parallelism': 800,
          'spark.locality.wait': 60,
          },
    jars='hdfs:///scheduler/jms/spark/chk/report/dynamic_route_data/common-1.0-SNAPSHOT.jar',  # 依赖 jar 包
    java_class='com.yunlu.bigdata.jobs.report.DynamicRouteDetailData',  # spark 主类
    application='hdfs:///scheduler/jms/spark/chk/report/dynamic_route_data/original-jobs-1.0-SNAPSHOT.jar',
    # spark jar 包
    application_args=['{{ execution_date  | date_add(1)| cst_ds }}'],  # 参数dt 跑数据当天

)

# 设置依赖
jms_dwd__dwd_dynamic_route_detail_dt << [
    jms_dwd__dwd_route_basic_detail_dt_input,
    jms_dwd__dwd_scan_detail_dt,
    jms_ods__yl_lmdm_sys_network,
    jms_ods__yl_tmsnew_tms_shipment_stop,
    jms_ods__yl_tmsnew_branch_shipment_stop,
    jms_ods__yl_tmsnew_tms_shipment,
    jms_ods__yl_tmsnew_branch_shipment,
    jms_ods__electronic_package_list,
    jms_ods__second_package_list,
    jms_ods__tab_report_errorbagging_detail,
    jms_dm__dm_waybill_collect_intime_detail,
    jms_dm__dm_cn_departure_transfer_timely_route_dt,
    jms_dm__dm_cn_departure_transfer_timely_route_dt_t2,
    jms_dwd__dwd_centersend_timerate_detail_dt
]
